package com.spsoft.vatoutinv.service.vmsclassifycode.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spsoft.core.model.Result;
import com.spsoft.core.utils.BeanUtils;
import com.spsoft.vatoutinv.entity.vmsclassifycode.VmsClassifyCodeLogIndustry;
import com.spsoft.vatoutinv.mapper.VmsClassifyCodeLogIndustryMapper;
import com.spsoft.vatoutinv.model.vo.vmsclassifycode.VmsClassifyCodeHyVO;
import com.spsoft.vatoutinv.service.vmsclassifycode.VmsClassifyCodeLogIndustryService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 税收分类编码信息查询记录-行业信息记录表 服务实现类
 * </p>
 *
 * @author wangy
 * @since 2023-11-23
 */
@Service
public class VmsClassifyCodeLogIndustryServiceImpl extends ServiceImpl<VmsClassifyCodeLogIndustryMapper, VmsClassifyCodeLogIndustry> implements VmsClassifyCodeLogIndustryService {

    @Override
    public Result<List<VmsClassifyCodeHyVO>> getHyListByCode(String id) {
        LambdaQueryWrapper<VmsClassifyCodeLogIndustry> query = new LambdaQueryWrapper<>();
        query.eq(VmsClassifyCodeLogIndustry::getClassifyCodeId, id);
        query.orderByAsc(VmsClassifyCodeLogIndustry::getId);
        List<VmsClassifyCodeLogIndustry> list = this.list(query);

        List<VmsClassifyCodeHyVO> vos = list.stream().map(item -> {
            VmsClassifyCodeHyVO vo = new VmsClassifyCodeHyVO();
            BeanUtils.copyBeanProp(vo, item);
            return vo;
        }).collect(Collectors.toList());
        return Result.OK(vos);
    }
}
